package cn.stylefeng.guns.sys.modular.plotHouseInfo.service;

import cn.stylefeng.guns.sys.modular.plotHouseInfo.model.TreeBean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LevelTree {

    private String id;
    private String label;
    //门号
    List<Map> children = new ArrayList();

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<Map> getChildren() {
        return children;
    }

    public void setChildren(List<Map> children) {
        this.children = children;
    }

    public LevelTree(String id, String label) {
        super();
        this.id = id;
        this.label = label;
    }

    public void addDoor(TreeBean bean) {
        if (children.stream().filter(i -> bean.getDoor_no().equals(i.get("doorNo"))).count() == 0) {
            //this.children.add(new LevelTree(XqTree.treeId++ +"", bean.getLevel_no()));
            Map map = new HashMap();
            //map.put("id", XqTree.treeId++);
            map.put("id", bean.getHouse_id());
            map.put("house_id", bean.getHouse_id());
            map.put("label", bean.getDoor_no() + "-" + bean.getPhone());
            map.put("doorNo", bean.getDoor_no());
            map.put("level", "1");
            map.put("plus", bean);
            this.children.add(map);
        }
    }
}

